# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libxml++
pkgbase=mingw-w64-${_realname}2.6
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}2.6"
pkgver=2.40.1
pkgrel=1
arch=('any')
pkgdesc="C++ wrapper for the libxml2 XML parser library (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-glibmm")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=('strip' 'staticlibs')
license=('LGPL')
url="https://libxmlplusplus.sourceforge.io/"
source=("https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz")
sha256sums=('4ad4abdd3258874f61c2e2a41d08e9930677976d303653cd1670d3e9f35463e9')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build="${MINGW_CHOST}" \
    --disable-static \
    --enable-shared

  # Hack for mingw python
  local PREFIX_DEPS=$(cygpath -am ${MINGW_PREFIX})
  find . -type f -name "Makefile" -exec sed -i "s|${PREFIX_DEPS}|${MINGW_PREFIX}|g" {} \;
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make install DESTDIR="${pkgdir}"
}
